package com.zeta.eduservice.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zeta.eduservice.entity.EduTeacher;
import com.zeta.eduservice.entity.question.EduQuestion;
import com.zeta.eduservice.entity.question.EduQuestionChoice;
import com.zeta.eduservice.entity.vo.Ata;
import com.zeta.eduservice.entity.vo.questionVo;
import com.zeta.eduservice.entity.vo.front.EduQuestionVo;
import com.zeta.eduservice.entity.vo.front.PdfQuestionVo;

/**
 * <p>
 * 试题 Mapper 接口
 * </p>
 *
 * @author zeta
 * @since 2020-08-25
 */
public interface EduQuestionMapper extends BaseMapper<EduQuestion> {
	List<EduQuestion> getsByCourseId(String courseId);
	List<EduQuestionVo> getsByfolderId(String folderId);
	List<PdfQuestionVo> getsPdfByfolderId(String folderId);
	List<PdfQuestionVo> getByRand(String type,Integer difficulty,Integer number);
	List<PdfQuestionVo> getByRandDetial(String type,Integer difficulty,Integer number,String chapterid);
	
	List<String> getType(String chapterid);
	Ata QuestionTypeCount(String courseid,String type);
	

	@Select("select b.*,a.id typeid  from chapter_a_question_type_sys_and_question a join edu_question b on a.question_id=b.id where a.is_deleted=0 and b.is_deleted=0 and a.regist_id=#{midid}")
	List<questionVo> getByMidId(Page<questionVo> page,@Param("midid") String midid);

	@Select("SELECT c.*,a.id typeid ,d.title chapter ,d.sort chaptersort FROM edu_chapter_and_question_type_sys a join chapter_a_question_type_sys_and_question b on a.id=b.regist_id join edu_question c on c.id=b.question_id " + 
			"join edu_chapter d on d.id=a.chapter_id" + 
			"where a.course_id=#{courseid} and a.question_type_sys_id=#{typesys} and a.is_deleted=0 and b.is_deleted=0 and c.is_deleted=0")
	List<questionVo> GetQuestionsByQuestionTypeSys(Page<questionVo> page,@Param("courseid") String courseid,@Param("typesys") String typesys);

	@Select("select b.*,a.id typeid from paper_type_and_question a join edu_question b on a.question_id=b.id where a.is_deleted=0 and b.is_deleted=0 and a.paper_type_id=#{midid}")
	List<questionVo> getByPaperTypeId(Page<questionVo> page,@Param("midid") String midid);
	@Select("select b.*,a.id typeid from paper_type_and_question a join edu_question b on a.question_id=b.id where a.is_deleted=0 and b.is_deleted=0 and a.paper_type_id=#{midid}")
	List<questionVo> getByPaperTypeId(String typeId);

}
